package com.ifcar.app.util;

import android.content.Context;
import android.widget.Toast;

/**
 * 代替业务逻辑中使用的Toast，目的是为了控制消息不断累积，特别是在monkey条件下
 * 现在是微博分享界面使用
 * @author zhangyp
 *
 */
public class MyToast {
    
    private static Toast tip;
    /**
     * Show the view or text notification for a short period of time.  This time
     * could be user-definable.  This is the default.
     * @see #setDuration
     */
    public static final int LENGTH_SHORT = 0;

    /**
     * Show the view or text notification for a long period of time.  This time
     * could be user-definable.
     * @see #setDuration
     */
    public static final int LENGTH_LONG = 1; 
    
    public static Toast makeText(Context context, CharSequence text, int duration){
        if(null!=tip){
            tip.cancel();
            tip = null;
        }
        tip = Toast.makeText(context, text, duration);
        return tip;
    }
    
    public static Toast makeText(Context context, int resId, int duration){
        if(null!=tip){
            tip.cancel();
            tip = null;
        }
        tip = Toast.makeText(context, resId, duration);
        return tip;
    }
    
}
